--
-- Author:      feilong
-- DateTime:    2019-10-30 10:59:15
-- Description: 节点中用户信息

local ServerType = require("ServerType")

local User = class("User")

function User:ctor(server_user, user_info)
    self.user_id = user_info.user_id --玩家id    
    self.user_name  = user_info.user_name --玩家名
    self.password  = user_info.password --玩家密码
    self.user_type = user_info.user_type or 0 --用户类型   

    self.server_info = server_info
	self.server_user = server_user    
end

function User:setData(data)
    for k, v in pairs(data) do 
    	self[k] = v
    end
end

function User:getUserInfo()

	return user_info
end

function User:getUserId()
	return self.user_id
end

function User:getUserType()
	return self.user_type
end

function User:getName()
	return self.user_name
end

function User:getServerUser()
	return self.server_user
end

function User:getGateServer()
	return self.server_user:getGateServer()
end

function User:getHallServer()
	return self.server_user:getHallServer()
end

function User:getNodeServer()
	return self.server_user:getNodeServer()
end

function User:getGameServer()
	return self.server_user:getGameServer()
end

function User:getServerByType(server_type)
	if server_type == ServerType.GATE then 
		return self:getGateServer()
	elseif server_type == ServerType.HALL then
		return self:getHallServer()
	elseif server_type == ServerType.GAME then 
		return self:getGameServer()
	elseif server_type == ServerType.NODE then
		return self:getNodeServer()
	end
	return
end

function User:getFD()
	return self.server_user:getFD()
end

function User:getClientInfo()
	return self.user_info
end



return User